var myScroller=$.ui.scrollingDivs['feed'];
  myScroller.addInfinite();
  myScroller.addPullToRefresh();

  //pull to refresh UI
  $.bind(myScroller, "refresh-trigger", function() {
    this.setRefreshContent("Release to refresh...");
  });
  var hideClose;
  $.bind(myScroller, "refresh-release", function() {
    var that = this;
    this.setRefreshContent("Loading...");
    setTimeout(function(){
      var itemID = $(".item").attr("data-id");
      data = fetchfacebookData('before',itemID); //fetch facebook data before latest post
      insertfacebookData(data,'refresh'); //prepend facebook data
    }, 1000);
    clearTimeout(hideClose);
    hideClose = setTimeout(function(){
      that.hideRefresh();
    }, 3000);
    return false;
  });
  $.bind(myScroller, "refresh-cancel", function() {
    clearTimeout(hideClose);
  });

  //bottom infinite scroll
  $.bind(myScroller,"infinite-scroll",function(){
    var itemID = $(".item:last-child").attr("data-date");
    var self=this;
    $(this.el).append("<div id='infinite'>Loading more...</div>");
    $.bind(myScroller,"infinite-scroll-end",function(){
      setTimeout(function(){
        data = fetchfacebookData('after',itemID); //fetch facebook data after latest bottom post date
        if (data) {
          insertfacebookData(data,'more');
        } else {
          $(self.el).find("#infinite").text('No more posts :(');
        }
      }, 2000);
      $.unbind(myScroller,"infinite-scroll-end");
      setTimeout(function(){
        $(self.el).find("#infinite").remove();
        self.clearInfinite();
      },3000);
    });
  });              

  myScroller.enable();